'''
增删改
'''

# 1.添加：
# .append
films = ['一人之下', '一拳超人', '不良人', '死亡笔记']
print(films)
films.append('秦时明月')
print(films)

# .insert
films.insert(1, '名侦探柯南')
print(films)

# .extend(序列)

# 2.删除
# del list[index]
del films[2]
print(films)

# .remove(元素)
nums = [1, 6, 90, 50, 6, 40]
nums.remove(6)
print(nums)

# .pop(index)
r = nums.pop()
print(nums)
print(r)
print('-------练习-----------------')
# 练习：删除列表中小于60的元素
scores = [89, 45, 56, 20, 90, 78, 60, 23, 87, 20, 50]
score = []
for i in scores:
    if i >= 60:
        score.append(i)
print(score)

scores = [89, 45, 56, 20, 90, 78, 60, 23, 87, 20, 50]

for i in scores[:]:
    if i < 60:
        scores.remove(i)
print(scores)
# 练习：将scores中所有小于60的分数修改为不及格
scores = [89, 45, 56, 20, 90, 78, 60, 23, 87, 20, 50]
for i in range(len(scores)):
    if scores[i] < 60:
        scores[i] = '不及格'
print(scores)

print('-----------')
nums = [3, 2, 4]
target = 6
for num1 in nums:
    num2 = target - num1
    print(num1,num2)  # 问题出在3 3
    if num2 in nums:
        index1 = nums.index(num1)
        index2 = nums.index(num2)
        print(index1, index2)
